<?
layout("/inc/layout.html",{title:sysTitle}){
?>
<div id="page-wrapper">
	<!--BEGIN TITLE & BREADCRUMB PAGE-->
	<div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
		<div class="page-header pull-left">
			<div class="page-title">自然语言处理</div>
		</div>
		<ol class="breadcrumb page-breadcrumb pull-left">
			<li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i
				class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li>自然语言处理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
			<li class="active">在线演示</li>
		</ol>
		<div class="clearfix"></div>
	</div>
	<!--END TITLE & BREADCRUMB PAGE-->
	<!--BEGIN CONTENT-->
	<div class="page-content">
		
		<img src="images/slide2.png" width="70%" height="100px;"/>
		
		<div class="row" style="margin-top: 10px;">
			<div class="col-lg-12" style="margin-top: 10px;">
				<div class="form-group">
					<div class="col-md-2" style="text-align:center"> 
						<label for="inputPhone" class="control-label">标题（title）:</label>
					</div>
					<div class="col-md-9">
						<input id="title" type="text" class="form-control"  name="title" value="美国航空静电喷雾系统的发展历史与中国应用现状" />
					</div>
				</div>
			</div>
			<br/>
			<div class="col-lg-12" style="margin-top: 10px;">
				<div class="form-group">
					<div class="col-md-2" style="text-align:center">
						<label for="inputPhone" class="control-label">关键字（keywords）:</label>
					</div>
					<div class="col-md-9">
						<input id="key" type="text" class="form-control"  name="key" value="喷雾;农业航空;静电喷雾;雾滴沉积;航空植保" />
					</div>
				</div>
			</div>
			<div class="col-lg-12" style="margin-top: 10px;">
				<div class="form-group">
					<div class="col-md-2" style="text-align:center">
						<label for="inputPhone" class="control-label">摘要（summary）:</label>
					</div>
					<div class="col-md-9">
						<textarea id="digest" name="digest" rows="4" class="form-control">航空静电喷雾系统是传统静电喷雾技术在空中操作平台上的专门应用,是航空植保技术的重要内容.美国在上个世纪60年代开始开展航空静电喷雾的技术研究,本文着重介绍了美国航空静电喷雾系统近50a的发展历史和相关的测试工作,包括航空静电喷雾系统的早期研究和持续改进,以及最终的系统模型确定.航空静电喷雾系统可有效减少施药液量和提高药液沉积量,但是仍然存在如何提高病虫害防治效果和减少下风处的喷雾飘移等方面的问题,航空静电喷雾系统针对不同作物和病虫害的适用范围和最佳作业条件还需要进一步的研究和探索.然而,航空静电喷雾系统的巨大优势已经奠定了地位.</textarea>
					</div>
				</div>
			</div>
			<div class="col-lg-12" style="margin-top: 10px;">
				<div class="form-group">
					<div class="col-md-2" style="text-align:center">
						<label for="inputPhone" class="control-label">正文（text）:</label>
					</div>
					<div class="col-md-9">
						<textarea id="text" name="text" rows="4" class="form-control"></textarea>
					</div>
				</div>
			</div>
			<div class="col-lg-12" style="margin-top: 10px;">
				<a href="#" onclick="submitForm();" class="btn btn-success pull-right">提交文本<i class="fa fa-rocket"></i></a>
			</div>
		</div>
		
		<div class="row">
			<div class="col-lg-12">
				<ul id="generalTab" class="nav nav-tabs ul-edit responsive">
					<li class="active"><a href="#dp-1" data-toggle="tab">词性标注</a></li>
					<li><a href="#dp-2" data-toggle="tab">基于词表标注</a></li>
					<li><a href="#dp-3" data-toggle="tab">实体识别</a></li>
					<li><a href="#dp-4" data-toggle="tab">依存句法分析</a></li>
					<li><a href="#dp-5" data-toggle="tab">自动摘要</a></li>
					<li><a href="#dp-6" data-toggle="tab">关键词提取</a></li>
					<li><a href="#dp-7" data-toggle="tab">语义联想</a></li>
				</ul>
				<div  class="tab-content responsive">
					<div id="dp-1" class="tab-pane fade in active">
						<div class="row" >
							<div class="col-lg-8" id="posbywordHtml">
								<h4>结果集：</h4>
								<button type="button" class="btn" style="margin-bottom: 5px; background-color: #EEDFCC; border: 1px solid #EEDFCC;">数据为空！</button>
							</div>
							<div class="col-lg-4" id="posbywordCategoryHtml">
								<h4>词性类别图示:</h4>
								<button type="button" class="btn" style="margin-bottom: 5px; background-color: #EEDFCC; border: 1px solid #EEDFCC;">数据为空！</button>
							</div>
						</div>
						
					</div>
					
					<div id="dp-2" class="tab-pane fade">
						<div class="row">
							<div class="col-lg-12" id="posTaggingHtml">
								<h4>结果集：</h4>
								<button type="button" class="btn" style="margin-bottom: 5px; background-color: #EEDFCC; border: 1px solid #EEDFCC;">数据为空！</button>
							</div>
							<!-- <div class="col-lg-4" id="posCategoryHtml">
								<h4>词性类别图示:</h4>
								<button type="button" class="btn" style="margin-bottom: 5px; background-color: #EEDFCC; border: 1px solid #EEDFCC;">数据为空！</button>
							</div> -->
						</div>
					</div>
					
					<div id="dp-3" class="tab-pane fade">
						<div class="row">
							<div class="col-lg-8" id="recHtml">
								<h4>结果集：</h4>
								<button type="button" class="btn" style="margin-bottom: 5px; background-color: #EEDFCC; border: 1px solid #EEDFCC;">数据为空！</button>
							</div>
							<div class="col-lg-4" id="recCategoryHtml">
								<h4>词表来源:</h4>
								<button type="button" class="btn" style="margin-bottom: 5px; background-color: #EEDFCC; border: 1px solid #EEDFCC;">数据为空！</button>
							</div>
						</div>
					</div>
					
					<!-- 依存句法分析 -->
					<div id="dp-4" class="tab-pane fade">
						<div class="row">
							<div class="col-lg-12">
								
								<dd class="mod_result_content result_sentence dependency_chart" style="overflow: auto;">
									数据为空！
								</dd>
								<dd class="mod_result_content result_tabs dependency_text">
									<div class="result_tabs_wrap result_tabs_wrap_first">
									</div>
								</dd>
								
							</div>
							 
						</div>
					</div>
					
					<!-- 自动摘要 -->
					<div id="dp-5" class="tab-pane fade">
						<div class="row">
							<div class="col-lg-12"  id="autoSummary">
								<div class="note">
                                    <p>数据为空！</p>
                                </div>
							</div>
						</div>
					</div>
					
					<!-- 关键词提取 -->
					<div id="dp-6" class="tab-pane fade">
						<div class="row">
						
							 <div class="col-lg-12"  id="autoKeyword">
								 <button type="button" class="btn" style="margin-bottom: 5px; background-color: #EEDFCC; border: 1px solid #EEDFCC;">数据为空！</button>
							</div>
							
						</div>
					</div>
					
					<!-- 语义联想 -->
					<div id="dp-7" class="tab-pane fade">
						<div class="row" id="wordDistanceHtml">
							<p>&nbsp;&nbsp; 数据为空！</p> 
						</div>
					</div>
					
					
				</div>
			</div>
		</div>
		
		

	</div>
	<!--END CONTENT-->
</div>

<link type="text/css" rel="stylesheet" href="static/dependency.css">

<script type="text/javascript" src="static/d3.min.js"></script>
<script type="text/javascript" src="static/lex.js"></script>
<script type="text/javascript" src="static/dependency.js"></script>

<SCRIPT type="text/javascript">

function submitForm() {
	var title = $("#title").val();
	var key = $("#key").val();
	var digest = $("#digest").val();
	var text = $("#text").val();
	if($.trim(title).length<1 && $.trim(key).length<1 && $.trim(digest).length<1 && $.trim(text).length<1) {
		alert("请输入待处理文本");
		return false;
	}
	submitPosTagging(title,key,digest,text);
	submitPosByWord(title,key,digest,text);
	submitRecognizeEntity(title,key,digest,text);
	submitDependencyParser(title,key,digest,text);
	submitAutoSummary(title,key,digest,text);
	submitAutoKeyword(title,key,digest,text);
	var wordDistanceText=title+key+digest+text;
	submitWordDistance(wordDistanceText);
}

//基于词表标注
function submitPosTagging(title,key,digest,text) {
	$.ajax({
		type: "post",
		url: "nlp-demo-posTagging.html",
		data: {
			"title": title,
			"keywords": key,
			"summary": digest,
			"text": text,
		},
		dataType: "json",
		success: function(data) {
			var posTaggingHtml = '<h4>结果集：</h4>';
			var posCategoryHtml = '<h4>词性类别图示:</h4>';
			if(data!=null && data!='') {
			posTaggingHtml +="<div style='margin-top: 10px;font-size:18px;'>title:&nbsp;&nbsp;&nbsp;"+data[0].title+"</div>"
							+"<div style='margin-top: 10px;font-size:18px;'>keywords:&nbsp;&nbsp;&nbsp;"+data[0].keywords+"</div>"
							+"<div style='margin-top: 10px;font-size:18px;'>summary:&nbsp;&nbsp;&nbsp;"+data[0].summary+"</div>"
							+"<div style='margin-top: 10px;font-size:18px;'>text:&nbsp;&nbsp;&nbsp;"+data[0].text+"</div>"
				 /* $(data[0].posTaggingList).each(function(i) {
					 posTaggingHtml += ' <button type="button" class="btn" style="margin-bottom: 5px; background-color: ' 
					 + data[0].posTaggingList[i].color + '; border: 1px solid ' + data[0].posTaggingList[i].color + ';">' 
					 + data[0].posTaggingList[i].word + '</button>';
			  	 });
				 $(data[0].posCategoryList).each(function(i) {
					 posCategoryHtml += ' <button type="button" class="btn" style="margin-bottom: 5px; background-color: ' 
					 + data[0].posCategoryList[i].color + '; border: 1px solid ' + data[0].posCategoryList[i].color + ';">' 
					 + data[0].posCategoryList[i].name + '</button>';
			  	 }); */
			}
			$("#posTaggingHtml").html(posTaggingHtml);
			//$("#posCategoryHtml").html(posCategoryHtml);
			
		},
		error : function(data) {
			// alert("请求失败");
		}
	});
}

// 依存分析
function submitDependencyParser(title,key,digest,text) {
	var dependencyParserText=title+key+digest+text;
	$.ajax({
		type: "post",
		url: "nlp-demo-dependencyParser.html",
		data: {
			"text": dependencyParserText
		},
		dataType: "json",
		success: function(data) {
			get_dependency(data[0]);
		},
		error : function(data) {
			// alert("请求失败");
		}
	});
}

//词性标注
function submitPosByWord(title,key,digest,text) {
	var posByWordText=title+key+digest+text;
	$.ajax({
		type: "post",
		url: "nlp-demo-posTaggingByWords.html",
		data: {
			"text": posByWordText
		},
		dataType: "json",
		success: function(data) {
			var posbywordHtml = '<h4>结果集：</h4>';
			var posbywordCategoryHtml = '<h4>词表来源:</h4>';
			if(data!=null && data!='') {
				 $(data[0].posTaggingList).each(function(i) {
					 posbywordHtml += ' <button type="button" class="btn" style="margin-bottom: 5px; background-color: ' 
					 + data[0].posTaggingList[i].color + '; border: 1px solid ' + data[0].posTaggingList[i].color + ';">' 
					 + data[0].posTaggingList[i].word + '</button>';
			  	 });
				 $(data[0].posCategoryList).each(function(i) {
					 posbywordCategoryHtml += ' <button type="button" class="btn" style="margin-bottom: 5px; background-color: ' 
					 + data[0].posCategoryList[i].color + '; border: 1px solid ' + data[0].posCategoryList[i].color + ';">' 
					 + data[0].posCategoryList[i].name + '</button>';
			  	 });
			}
			$("#posbywordHtml").html(posbywordHtml);
			$("#posbywordCategoryHtml").html(posbywordCategoryHtml);
			
		},
		error : function(data) {
			// alert("请求失败");
		}
	});
}

//实体识别
function submitRecognizeEntity(title,key,digest,text) {
	var recognizeEntityText=title+key+digest+text;
	$.ajax({
		type: "post",
		url: "nlp-demo-recognizeEntity.html",
		data: {
			"text": recognizeEntityText
		},
		dataType: "json",
		success: function(data) {
			var recHtml = '<h4>结果集：</h4>';
			var recCategoryHtml = '<h4>词表来源:</h4>';
			if(data!=null && data!='') {
				 $(data[0].posTaggingList).each(function(i) {
					 recHtml += ' <button type="button" class="btn" style="margin-bottom: 5px; background-color: ' 
					 + data[0].posTaggingList[i].color + '; border: 1px solid ' + data[0].posTaggingList[i].color + ';">' 
					 + data[0].posTaggingList[i].word + '</button>';
			  		
			  	
			  	 });
			  	 
				  $(data[0].result).each(function(i) {
					 
			  		 recCategoryHtml += ' <button type="button" class="btn" style="margin-bottom: 5px; background-color: ' 
					 + data[0].result[i].color + '; border: 1px solid ' + data[0].result[i].color + ';">' 
					 + data[0].result[i].name + '</button>';
			  	
			  	 });
			}
			$("#recHtml").html(recHtml);
			$("#recCategoryHtml").html(recCategoryHtml);
			
		},
		error : function(data) {
			// alert("请求失败");
		}
	});
}

//自动摘要
function submitAutoSummary(title,key,digest,text) {
var autoSummaryText=title+key+digest+text;
	$.ajax({
		type: "post",
		url: "nlp-demo-autoSummary.html",
		data: {
			"text": autoSummaryText,
		},
		dataType: "json",
		success: function(data) {
			var autoSummary ="";
			if(data!=null && data!='') {
					 $(data[0].summaryText).each(function(i) {
						 autoSummary += data[0].summaryText[i] + "；";
				  	 });
			}
			$("#autoSummary").html(autoSummary);
			
		},
		error : function(data) {
			// alert("请求失败");
		}
	});
}

//关键词提取
function submitAutoKeyword(title,key,digest,text) {
	$.ajax({
		type: "post",
		url: "nlp-demo-autoKeyword.html",
		data: {
			"title": title,
			"keywords": key,
			"summary": digest,
			"text": text,
		},
		dataType: "json",
		success: function(data) {
			var autoKeyword = '';
			if(data!=null && data!='') {
				 $(data[0].keywordList).each(function(i) {
					 autoKeyword += ' <button type="button" class="btn btn-info" style="margin-bottom: 5px;">' 
					 + data[0].keywordList[i] + '</button>';
			  	 });
			}
			$("#autoKeyword").html(autoKeyword);
		},
		error : function(data) {
			// alert("请求失败");
		}
	});
}

//语义联想
function submitWordDistance(wordDistanceText, word) {
	$.ajax({
		type: "post",
		url: "nlp-demo-wordDistance.html",
		data: {
			"word": word,
			"text": wordDistanceText,
		},
		dataType: "json",
		success: function(data) {
			var wordDistanceHtml = ""; // 追加內容
			if(data!=null && data!='') {
				 var keywordsOptionStr='';
				 $(data[0].keywordsList).each(function(i) {
					 if(data[0].word==data[0].keywordsList[i]) {
						 keywordsOptionStr +='<option value="' + data[0].keywordsList[i] + '" selected>' + data[0].keywordsList[i] + '</option>';
					 }else {
						 keywordsOptionStr +='<option value="' + data[0].keywordsList[i] + '">' + data[0].keywordsList[i] + '</option>';
					 }
					 
			  	 });
				 $("#wordDistanceHtml").html('<div class="col-lg-12" style="margin-left: -10px;">'
						 		+'<div style="float:left; display: inline"><h4 style="margin-left: 18px;">关键词:&nbsp;&nbsp;</h4 ></div>'
								+'<div>'
								+'<select id="keywordsList" onchange="submitWordDistance( \''+wordDistanceText + '\',this.value)" style="width: 180px;" id="isTopTerm" class="form-control">'
								+ keywordsOptionStr
								+'</select>'
								+'</div>'
								+'</div>');
			  	 // n%5
			  	 var wordDistanceTableStart='<div class="col-lg-6">'							
						+'<table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">'
						+'<thead>'
						+'<tr>'                 
						+'<th>名称</th><th>相关性</th>'
						+'</tr>'
						+'</thead>'
						+'<tbody>';
				var wordDistanceTableEnd = '</tbody></table></div>';
				var wordDistanceTr = '';
			  	 $(data[0].wordDistanceList).each(function(i) {
			  		wordDistanceTr+='<tr><td>'+ data[0].wordDistanceList[i].wordA +'</td><td>'+ data[0].wordDistanceList[i].similarity +'</td></tr>';
			  	    if((i+1)%5==0) {
			  	    	$("#wordDistanceHtml").append(wordDistanceTableStart + wordDistanceTr + wordDistanceTableEnd);
			  	    	wordDistanceTr='';
			  	    }
			  	 });
			}
		},
		error : function(data) {
			// alert("请求失败");
		}
	});
}
</SCRIPT>


<?} ?>

